﻿using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Xml.Linq;
using System.Xml;
using System.Collections;

namespace ConsoleApplication1
{
  public class MyList : ArrayList
    {
       public void save(string path) 
        {
            Factory.gi(path).save(this);            
        }
       public void load(string path)
        {
            this.Clear();
            this.AddRange(Factory.gi(path).load());
        }
    }
    
    class objects
    {
        static void Main(string[] args)
        {
            MyList expected = new MyList();

            expected.Add(new book { id = 5, CopyCount = 5, Cost = 2.00, PredC = 2, Author = "Author" });
            expected.Add(new magazine { id = 2, CopyCount = 5, Cost = 2.00, PCount = 2, Izd = "Author" });
            expected.Add(new book { id = 3, CopyCount = 5, Cost = 2.00, PredC = 2, Author = "Author" });
            expected.Add(new book { id = 4, CopyCount = 5, Cost = 2.00, PredC = 2, Author = "Author" });
            expected.Add(new book { id = 2, CopyCount = 5, Cost = 2.00, PredC = 2, Author = "Author" });

            expected.save(@"c:\temp\MyTest.yaml");
            /*
            MyList b = new MyList();
            b.load(@"c:\temp\MyTest.xml");
          //  b = b.load(@"c:\temp\MyTest.xml");

            foreach (items p in b)
            {
                Console.WriteLine(b[0].ToString());
            }*/
            expected.Clear();
            expected.load(@"c:\temp\MyTest.yaml");
            expected.save(@"c:\temp\MyTest2.yaml");
            foreach (items p in expected)
            {
                Console.WriteLine(expected[0].ToString());
            }
           Console.ReadKey();
           
        }   
    }


}
